0 REM TRACE
110 CLS:GRAPH
120 FOR I=1 TO 79 STEP 2
130 BOX I,I,160-I,80-I:REM __DEBUG I,I,160-I,80-I:K$=INKEY$:CLS
140 NEXT I
150 LOCATE 3,5:PRINT "万能数学V1.0"
160 C$=INKEY$
170 FOR I=80 TO 160
180 LINE I,0,I,80,0
190 LINE 160-I,0,160-I,80,0
200 NEXT I
300 GRAPH:CLS:PRINT "   万能数学宝V1.0"
310 PRINT "1 质数检查"
320 PRINT "2 求公约数/公倍数"
330 PRINT "3 解一元二次方程"
340 PRINT "4 解二元一次方程组";
350 C$=INKEY$
360 IF C$=CHR$(21) THEN 400
370 IF C$="b" THEN 500 ELSE IF C$="n" THEN 700
380 IF C$="m" THEN 900 ELSE IF C$="g" THEN 1100 ELSE 350
400 LOCATE 2,1 :PRINT "5 绘制一次方程图象 "
410 PRINT "6 绘制二次方程图象"
420 PRINT "                   "
430 PRINT "                   ";
440 C$=INKEY$
450 IF C$=CHR$(20) THEN 300 ELSE IF C$="h" THEN 1300
460 IF C$="j" THEN 1600 ELSE 440
500 CLS:TEXT :PRINT "      质数检查"
510 INPUT "请输入要检查的数：  ";N
520 IF N<=0 OR N<>INT(N) THEN 580
530 IF N=1 THEN 590 ELSE IF N=2 THEN 600
535 LOCATE 4,1:PRINT "检查中..."
540 FOR I=2 TO SQR(N)
550 IF N/I=INT(N/I) THEN 610 
560 NEXT I
570 GOTO 600
580 PRINT "请输入一个正整数":C$=INKEY$: GOTO 500
590 PRINT "1不是质数也不是合数":C$=INKEY$: GOTO 300
600 LOCATE 4,1:PRINT N;" 是质数";:C$=INKEY$: GOTO 300
610 LOCATE 4,1:PRINT N;" 是合数",N;"=";I;"*";N/I;:C$=INKEY$: GOTO 300
700 CLS:TEXT :PRINT "   求:最大公约数          最小公倍数"
710 INPUT "第一个数:";N1
720 INPUT "第二个数:";N2
730 IF N1<=0 OR N1<>INT(N1) OR N2<=0 OR N2<>INT(N2) THEN 790
740 N1P=N1:N2P=N2:IF N1<N2 THEN T=N2:N2=N1:N1=T
750 R=N1-N2*INT(N1/N2)
760 IF R=0 THEN 800
770 N1=N2:N2=R:R=N1-N2*INT(N1/N2)
780 GOTO 760
790 PRINT "请输入两个正整数   ";:C$=INKEY$: GOTO 700
800 LOCATE 3,1:PRINT SPC (59);
810 LOCATE 3,1:PRINT N1P;"、";N2P;"的最大公约数为";N2;" 最小公倍数为";N1P*N2P/N2;
820 C$=INKEY$: GOTO 300
900 CLS:TEXT :PRINT "   解一元二次方程"
910 PRINT "ax";CHR$(11);"+bx+c=0"
920 INPUT "a=";A
930 INPUT "b=";B
940 INPUT "c=";C
950 IF A=0 THEN 1030
960 N=B*B-4*A*C
970 IF N<0 THEN 1050
980 N1=(-B+SQR(N))/2/A
990 N2=(-B-SQR(N))/2/A
1000 CLS:PRINT "   解一元二次方程","ax";CHR$(11);"+bx+c=0"
1010 LOCATE 3,1:PRINT "x1=";N1,"x2=";N2;
1020 C$=INKEY$: GOTO 300
1030 CLS:PRINT "   解一元二次方程","ax";CHR$(11);"+bx+c=0","非一元二次方程"
1040 C$=INKEY$: GOTO 900
1050 CLS:PRINT "   解一元二次方程","ax";CHR$(11);"+bx+c=0","无解"
1060 C$=INKEY$: GOTO 900
1100 CLS:TEXT :PRINT "  解二元一次方程组"
1110 PRINT "a1x+b1y+c1=0","a2x+b2y+c2=0"
1120 LOCATE 4,1:INPUT "a1=";A1:LOCATE 4,1:PRINT SPC (39);:LOCATE 5,1
1130 LOCATE 4,1:INPUT "b1=";B1:LOCATE 4,1:PRINT SPC (39);:LOCATE 5,1
1140 LOCATE 4,1:INPUT "c1=";C1:LOCATE 4,1:PRINT SPC (39);:LOCATE 5,1
1150 LOCATE 4,1:INPUT "a2=";A2:LOCATE 4,1:PRINT SPC (39);:LOCATE 5,1
1160 LOCATE 4,1:INPUT "b2=";B2:LOCATE 4,1:PRINT SPC (39);:LOCATE 5,1
1170 LOCATE 4,1:INPUT "c2=";C2:LOCATE 4,1:PRINT SPC (39);:LOCATE 5,1
1180 N2=(A2*C1-A1*C2)/(A1*B2-A2*B1)
1190 N1=(-C1-B1*N2)/A1
1200 LOCATE 4,1:PRINT SPC (39);
1210 LOCATE 4,1:PRINT "x=";N1,"y=";N2;
1220 C$=INKEY$: GOTO 300
1300 CLS:TEXT :PRINT "  绘制一次方程图象"
1310 PRINT "ax+by+c=0"
1320 LOCATE 3,1:INPUT "a=";A:LOCATE 3,1:PRINT SPC (59);:LOCATE 4,1
1330 LOCATE 3,1:INPUT "b=";B:LOCATE 3,1:PRINT SPC (59);:LOCATE 4,1
1340 LOCATE 3,1:INPUT "c=";C:LOCATE 3,1:PRINT SPC (59);:LOCATE 4,1
1350 IF A=0 AND B=0 THEN GRAPH:PRINT "您的输入有误，请重试" ELSE  GOTO 1370
1360 C$=INKEY$: GOTO 1300
1370 GRAPH:CLS:LINE 1,40,80,40
1380 LINE 40,0,40,79
1390 LINE 40,0,35,5
1400 LINE 40,0,45,5
1410 LINE 80,40,75,35
1420 LINE 80,40,75,45
1430 LOCATE 1,11:PRINT "一次方程："
1440 LOCATE 2,11:PRINT "ax+by+c=0"
1450 LOCATE 3,11:PRINT "a=";A
1460 LOCATE 4,11:PRINT "b=";B
1470 LOCATE 5,11:PRINT "c=";C;
1480 IF B=0 THEN LINE -C/A+40,0,-C/A+40,79 ELSE 1500
1490 C$=INKEY$: GOTO 300
1500 IF A=0 THEN LINE 1,C/B+40,80,C/B+40 ELSE 1520
1510 C$=INKEY$: GOTO 300
1520 FOR I=-40 TO 39
1530 J=-I*A/B-C/B:K=I+1:L=-K*A/B-C/B
1540 IF J>-40 AND J<40 AND K>-40 AND K<40 THEN LINE I+40,-J+40,K+40,-L+40 ELSE 1550
1550 NEXT I
1560 C$=INKEY$: GOTO 300
1600 GRAPH:CLS
1610 PRINT "  绘制二次方程图象"
1620 PRINT "1、标准椭圆"
1630 PRINT "2、标准双曲线"
1640 PRINT "3、标准抛物线"
1650 C$=INKEY$:IF C$="b" THEN 1700 ELSE 1660
1660 IF C$="n" THEN 2000 ELSE IF C$="m" THEN 2300 ELSE 1670
1670 IF C$=CHR$(27) THEN 300 ELSE 1650
1700 CLS:TEXT :PRINT "  绘制标准椭圆图象"
1710 PRINT "x";CHR$(11);"/a";CHR$(11);"+y";CHR$(11);"/b";CHR$(11);"=1"
1720 INPUT "a=";A
1730 LOCATE 3,1:PRINT SPC (59);:LOCATE 3,1
1740 INPUT "b=";B
1750 C=SQR(ABS(A*A-B*B))
1760 IF A<=0 OR B<=0 THEN 1770 ELSE 1780
1770 GRAPH:CLS:PRINT "您的输入有误，请重试":C$=INKEY$: GOTO 1700
1780 IF A=B THEN GRAPH:CLS:PRINT "非椭圆" ELSE 1800
1790 C$=INKEY$: GOTO 1700
1800 GRAPH:CLS:LINE 1,40,80,40
1810 LINE 40,0,40,79
1820 LINE 40,0,35,5
1830 LINE 40,0,45,5
1840 LINE 80,40,75,35
1850 LINE 80,40,75,45
1860 LOCATE 3,11:PRINT " 椭圆图象"
1870 ELLIPSE 40,40,A,B
1880 IF A>B THEN LINE -C+40,39,-C+40,41:LINE C+40,39,C+40,41 ELSE 1890
1890 IF B>A THEN LINE 39,-C+40,41,-C+40:LINE 39,C+40,41,C+40
1900 D=((A+B+ABS(A-B))/2)^2/C:IF D>0 AND D<=40 THEN 1910 ELSE 1930
1910 IF A>B THEN LINE -D+40,1,-D+40,80:LINE D+40,1,D+40,80
1920 IF B>A THEN LINE 0,-D+40,80,-D+40:LINE 0,D+40,80,D+40
1930 C$=INKEY$: GOTO 300
2000 TEXT :CLS:PRINT " 绘制标准双曲线图象"
2010 PRINT "x";CHR$(11);"/a";CHR$(11);"-y";CHR$(11);"/b";CHR$(11);"=1"
2020 INPUT "a=";A
2025 LOCATE 3,1:PRINT SPC (59);:LOCATE 3,1
2030 INPUT "b=";B
2040 C=SQR(ABS(A*A-B*B))
2050 IF A<=0 OR B<=0 THEN 2060 ELSE 2080
2060 GRAPH:CLS:PRINT "您的输入有误，请重试"
2070 C$=INKEY$: GOTO 2000
2080 GRAPH:CLS:LINE 1,40,80,40
2090 LINE 40,0,40,79
2100 LINE 40,0,35,5
2110 LINE 40,0,45,5
2120 LINE 80,40,75,35
2130 LINE 80,40,75,45
2140 LOCATE 3,11:PRINT "双曲线图象"
2150 FOR I=-40 TO -A-1
2160 J=SQR(I*I/A/A-1)*B:K=I+1:L=SQR(K*K/A/A-1)*B
2200 IF J>-40 AND J<40 AND K>-40 AND K<40 THEN 2210 ELSE 2230
2210 LINE I+40,-J+40,K+40,-L+40:LINE 40-I,-J+40,40-K,-L+40
2220 LINE I+40,J+40,K+40,L+40:LINE 40-I,J+40,40-K,L+40
2230 NEXT 
2240 C$=INKEY$: GOTO 300

